import inspect, unittest, xmlrunner
from selenium import selenium

class TESTVerifications(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.selenium = selenium("localhost", 4444, "*iexplore", "https://workflowy.com/")
        self.selenium.start() 
        self.selenium.set_timeout("60000")
        print("setUpClass")      
        self.selenium.window_maximize()
        self.selenium.open("/")
        
    
    def setUp(self):
        self.verificationErrors = []
        
    def test_verification1_error(self):
        try: self.assertEqual("This application is designed", "This application is designedZZZZ",(inspect.stack()[0][3]) +" text missing 'This application is designed'")
        except AssertionError, e: self.verificationErrors.append(str(e))
    def test_verification2_error_two_times(self): 
        sel = self.selenium
        ##No such element exception
        try: self.assertEqual("First failure", "First failureZZZZ",(inspect.stack()[0][3]) +" First failure'")
        except AssertionError, e: self.verificationErrors.append(str(e))
        try: self.assertEqual("Second Failure", "Second FailureZZZZ",(inspect.stack()[0][3]) +" Second failure'")
        except AssertionError, e: self.verificationErrors.append(str(e))
        
    def tearDown(self):
        #self.selenium.stop()
        self.assertEqual([], self.verificationErrors,"Results: " + str(self.verificationErrors))
    @classmethod    
    def tearDownClass(self):
        
        self.selenium.stop()
        print("tearDownClass")

if __name__ == "__main__":
#    unittest.main()
    unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))